package com.mark.service.impl;

import com.mark.entity.school.UGrade;
import com.mark.mapper.UGradeMapper;
import com.mark.service.UGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * (UGrade)表服务实现类
 *
 * @author Deng PengFei
 * @since 2021-10-27 11:17:04
 */

@Service
public class UGradeServiceImpl implements UGradeService {

    @Autowired
    private UGradeMapper uGradeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param graId 主键
     * @return 实例对象
     */
    @Override
    public UGrade queryById(Integer graId) {
        return this.uGradeMapper.queryByGraId(graId);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     */
    @Override
    public List<UGrade> queryAll() {
        return this.uGradeMapper.queryAll();
    }

    /**
     * 新增数据
     *
     * @param uGrade 实例对象
     * @return 实例对象
     */
    @Override
    public UGrade insert(UGrade uGrade) {
        this.uGradeMapper.insert(uGrade);
        return uGrade;
    }

    /**
     * 修改数据
     *
     * @param uGrade 实例对象
     * @return 实例对象
     */
    @Override
    public UGrade update(UGrade uGrade) {
        this.uGradeMapper.update(uGrade);
        return this.queryById(uGrade.getGraId());
    }

    /**
     * 通过主键删除数据
     *
     * @param graId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer graId) {
        return this.uGradeMapper.deleteById(graId) > 0;
    }
}